package com.apache.ius.plugins;

import com.apache.api.vo.ParamsVo;
import com.apache.ius.plugin.CustomMethodPlugin;
import com.apache.portal.common.oscache.BaseOsCache;
import com.apache.portal.common.oscache.OsCacheOtherManager;
import org.apache.log4j.Logger;

import java.util.Map;


/**
 * 创建的测试插件
 * @Author IUS platform administrators create generation
 * @Date 2019-4-22 11:22:19
 */
public class TestNumCountPluginImpl implements CustomMethodPlugin {
	private Logger log = Logger.getLogger(getClass());

	@Override
	public Object beforeInvoke(Map<String, Object> param) {
		log.info("start->> 执行插件事前方法....");
		System.out.println(param);

		return null;
	}

	@Override
	public Object doInvoke(Map<String, Object> param) {
		log.info("start->> 执行插件方法....");

		return null;
	}

	@Override
	public Object afterInvoke(Map<String, Object> param) {
		log.info("start->> 执行插件事后方法....");
		String mobile = String.valueOf(param.get("uctUser.mobile"));
		BaseOsCache oscache = OsCacheOtherManager.getInstance().getBaseOsCache("mobile_obj_", 100);
		String req_code = String.valueOf(param.get("code"));;
		String smsCode_old = String.valueOf(oscache.get(mobile));
		if(!smsCode_old.equals(req_code)){
			System.out.println("验证码输入有误！");
		}
		return null;
	}

	/**
	 * 规则校验统一入口
	 * @param paramsVo
	 */
	public void run(ParamsVo paramsVo) {
		beforeInvoke(paramsVo.getParams());
	}


}

